// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/visitor/api/VisitorAppointmentApi'

import OneClass from '@api/visitor/model/QueryVisitorAppointmentDetailReq'
import RejClass from '@api/visitor/model/CancelVisitorAppointmentReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 单项 —————————————————————————————— //

  async getOne({ id }, TIP = '查询单项') {
    const DTO = CORE.grpcDTO(OneClass, { id })
    const resp = await CORE.grpc(TIP, CLIENT, 'queryMyVisitorAppointmentDetail', DTO)
    return resp
  },
  transOne(obj, { state: { one } }) {
    const auditStatus = obj.cancelStatus === 1 ? 9 : obj.auditStatus
    return { ...one, ...obj, auditStatus }
  },

  // —————————————————————————————— 拒绝 —————————————————————————————— //

  async rej({ id }, TIP = '拒绝') {
    const DTO = CORE.grpcDTO(RejClass, { id })
    await CORE.grpc(TIP, CLIENT, 'cancelVisitorAppointment', DTO)
    return CORE.grpcOK(TIP)
  },
}
